package top.swimmer.concurrent.thread;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        Map<Integer, List<Integer>> dealOrders = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            List<Integer> list = new ArrayList<>();
            list.add(100);
            dealOrders.put(i, list);
        }

        for (int i = 0; i < 10; i++) {
            if (dealOrders.containsKey(i)) {
                dealOrders.get(i).add(i);
            } else {
                List<Integer> orderIds = new ArrayList<>();
                orderIds.add(i);
                dealOrders.put(i, orderIds);
            }
        }

        System.out.println(dealOrders);
    }

    public static LocalDate daysBefore(int day) {
        return LocalDate.now().minusDays(day);
    }

    public static long beginTimeOfToday(LocalDate localDate) {
        return localDate.atStartOfDay()
                .atZone(ZoneId.systemDefault())
                .toInstant()
                .getEpochSecond();
    }

    public static long daysBeforeEpochSeconds(int day) {
        return beginTimeOfToday(daysBefore(day));
    }
}
